Allow updating of /IGNORE timeouts in ERC
authorF. Jason Park <jp@neverwas.me>
Mon, 1 Apr 2024 22:27:47 +0000 (15:27 -0700)
committerF. Jason Park <jp@neverwas.me>
Sun, 7 Apr 2024 19:59:21 +0000 (12:59 -0700)
commite0df2841fb78251d5461a17e2d9be581c152bdc2
treec69f5b6ad1b26189ba196bec9a4e18e1435a638b
parentc1266d355a2801271f2f875a1f7d47030c6c0e7a
Allow updating of /IGNORE timeouts in ERC

* lisp/erc/erc.el (erc--read-time-period, erc--decode-time-period):
Move body of former, now a superficial wrapper, to latter, a new
function.
(erc--format-time-period): New function.
(erc--get-ignore-timer-args): New function.
(erc--find-ignore-timer): New function to search through `timer-list'
to find matching ignore timer.
(erc-cmd-IGNORE): Refactor and redo doc string.  Add new optional
`timespec' parameter, primarily to aid in testing.  Update an existing
timer instead of always creating one, and display time remaining in
"ignore list" output.  Pass server buffer instead of current buffer to
timer callbacks because `erc--unignore-user' displays its messages in
the `active' buffer, not necessarily the issuing one.  Note that doing
this does discard potentially useful information, so if ever reverting,
we can change the `cl-find' :test in `erc--find-ignore-timer' to
something that compares the `erc-server-process' of both buffers.
;;
;; Something like:
;;
;; (defun erc--ignore-timers-equal-p (a b)
;;   (and (equal (car a) (car b))
;;        (eq (buffer-local-value 'erc-server-process (cadr a))
;;            (buffer-local-value 'erc-server-process (cadr b)))))
;;
(erc-cmd-UNIGNORE): Pass `erc-ignore-list' member matching `user'
parameter to `erc--unignore-user' instead of original, raw parameter,
along with the server buffer.
(erc--unignore-user): Cancel existing timer and don't bother switching
to server buffer since we're already there.
(erc-message-english-ignore-list): New variable.
* test/lisp/erc/erc-scenarios-ignore.el: New file.
* test/lisp/erc/erc-tests.el (erc--read-time-period): New test.
(erc-cmd-UNIGNORE): New test.  (Bug#70127)
lisp/erc/erc.el
test/lisp/erc/erc-scenarios-ignore.el [new file with mode: 0644]
test/lisp/erc/erc-tests.el